using UnityEngine;
using UnityEngine.UI;

public class AudioButton : MonoBehaviour {

    Button Btn;
    public bool BGM = false;
    public AudioNames.ID id;
    public float timeDelay = 0;

    private void Awake()
    {
        Btn = gameObject.GetComponent<Button>();
    }

    private void OnEnable()
    {
        StartCoroutine(TimeManager.DelayAction(timeDelay,Play));
    }
    private void Play()
    {
        if (Btn != null)
        {
            Btn.onClick.AddListener(delegate () {
                AudioMgr.Play((int)id, BGM);
            });
        }
        else
        {
            AudioMgr.Play((int)id, BGM);
        }
    }
}
